<!DOCTYPE html>
<html lang="en" xmlns:th="">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客详情页</title>
    <link rel="icon" th:href="@{/images/blog.png}" sizes="32x32">
</head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
<link rel="stylesheet" href="../static/css/typo.css" th:href="@{/css/typo.css}">
<link rel="stylesheet" href="../static/css/me.css" th:href="@{/css/me.css}">
<link rel="stylesheet" href="../static/lib/prism/prism.css" th:href="@{/lib/prism/prism.css}">
<link rel="stylesheet" href="../static/lib/tocbot/tocbot.css" th:href="@{/lib/tocbot/tocbot.css}">
<!-- 音乐播放器 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">

<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
<link rel="stylesheet" href="../static/css/mouseeffect.css.css" th:href="@{/css/mouseeffect.css}">
<style>
    body {
        background: url('https://static.talkxj.com/articles/f21704d1596d904d78cffd36293573a5.png') center center / cover no-repeat;
        background-attachment: fixed;

    }

    .img {
        display: block;
        margin: 100px auto;
        width: 260px;
        height: 260px;
        border-radius: 50%;
        border: 1px solid #C0C0C0;
        transition: all 500ms;
    }

    .img:hover {
        transform: rotate(320deg);
    }

    .t-hover-shadow {
        transition: transform .3s ease-in-out, box-shadow .3s cubic-bezier(.47, 0, .745, .715), border .3s linear .1s;
    }

    .t-hover-shadow:hover {
        box-shadow: 0 10px 50px rgba(51, 51, 51, .25);
        -webkit-transform: translateY(-10px);
        -moz-transform: translateY(-10px);
        transform: translateY(-10px)
    }

</style>

<body>

<!-- 导航 -->
<nav th:replace="_fragments :: menu(1)"></nav>

<!-- 中间内容 -->
<div id="waypoint" class="m-padded-tb-large animate__animated animate__fadeIn">
    <div class="ui container t-hover-shadow">
        <div class="ui top attached segment">
            <!-- 名字 -->
            <div class="ui mini horizontal link list">
                <div class="item">
                    <img src="https://picsum.photos/seed/picsum/100/100" alt="" class="ui avatar image"
                         th:src="@{${blog.user.avatar}}">
                    <!-- 名字 -->
                    <div class="content"><a class="header" th:src="@{${blog.user.nickname}}">Joker</a></div>
                </div>
                <!-- 发布时间 -->
                <div class="item">
                    <i class="calendar icon"></i> <span
                        th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd')}"></span>
                </div>
                <!--阅读量 -->
                <div class="item">
                    <i class="eye icon"></i>&nbsp;<span th:text="${blog.views}"></span>
                </div>
            </div>
        </div>
        <!-- 图片 -->
        <div class="ui attached segment">
            <img src="https://www.static.talkxj.com/config/2a56d15dd742ff8ac238a512d9a472a1.jpg" alt=""
                 class="ui fluid rounded image" th:src="@{${blog.firstPicture}}">
        </div>
        <!-- 内容 -->


        <div class="ui attached segment forFlow">
            <div class="ui right aligned basic segment">
                <div class="ui orange label" th:text="${blog.flag}"></div>
            </div>
            <h2 class="ui center aligned header" th:text="${blog.title}"></h2>
            <br>
            <!-- 博客主体内容 -->
            <div id="content" class="typo typo-selection m-padded-left-reponsive js-toc-content"
                 th:utext="${blog.content}">
            </div>


            <!-- 博客标签 -->
            <div class="m-padded-left-reponsive m-padded-tb-tinyy">
                <div class="ui basic teal left pointing label" th:each="tag : ${blog.tags}" th:text="${tag.name}">测试标签
                </div>
            </div>

            <!-- 赞赏功能 -->
            <div class="ui center aligned basic segment" th:if="${blog.appreciation}">
                <div id="app">
                    <el-popover placement="bottom" title="支付宝============微信" width="260" trigger="click">
                        <el-image style="width: 100px; height: 100px" :src="url1" :fit="fit"></el-image>
                        <el-image style="width: 100px; height: 100px;position: absolute; left: 150px;" :src="url2"
                                  :fit="fit"></el-image>
                        <el-button slot="reference">打赏</el-button>
                    </el-popover>
                </div>
            </div>
        </div>

        <!-- 博客信息 -->
        <div class="ui attached positive message" th:if="${blog.shareStatement}">
            <div class="ui middle aligned grid">
                <div class="eleven wide column">
                    <ui class="list">
                        <li>作者：<span th:text="${blog.user.nickname}"><a th:href="@{/about}">(联系作者)</a></span></li>
                        <li>发表时间：<span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd HH:mm')}"></span></li>
                        <li>版权声明：自由转载-非商用-非衍生-保持署名</li>
                        <li>公众号转载：请在文末添加作者信息</li>
                    </ui>
                </div>
                <div class="five wide column">
                    <img src="../static/images/zfb.png" th:src="@{/images/zfb.png}" alt=""
                         class="ui right floated rounded bordered image"
                         style="width: 130px;">
                </div>
            </div>
        </div>
        <div class="ui bottom attached segment" th:if="${blog.commentabled}">
            <!-- 留言区域 -->
            <div id="comment-container" class="ui teal segment">
                <div th:fragment="commentList">
                    <div class="ui threaded comments" style="max-width: 100%;">
                        <h3 class="ui dividing header">评论</h3>
                        <div class="comment" th:each="comment : ${comments}">
                            <a class="avatar">
                                <img class="img" style="border-radius: 20px"
                                     src="https://unsplash.it/100/100?image=1005"
                                     th:src="@{${comment.avatar}}">
                            </a>
                            <div class="content">
                                <a class="author">
                                    <span th:text="${comment.nickname}">Matt</span>
                                    <div class="ui mini orange  label m-padded-mini"
                                         th:if="${comment.adminComment}">博主
                                    </div>
                                </a>
                                <div class="metadata">
                                    <span class="date"
                                          th:text="${#dates.format(comment.createTime,'yyyy-MM-dd hh:mm')}">Today at 5:42PM</span>
                                </div>
                                <div class="text" th:text="${comment.content}">
                                    How artistic!
                                </div>
                                <div class="actions">
                                    <a class="reply" data-commentid="1" data-commentnickname="Matt"
                                       th:attr="data-commentid=${comment.id},data-commentnickname=${comment.nickname}"
                                       onclick="reply(this)">回复</a>
                                </div>
                            </div>
                            <div class="comments" th:if="${#arrays.length(comment.replyComments)}>0">
                                <div class="comment" th:each="reply : ${comment.replyComments}">
                                    <a class="avatar">
                                        <img class="img" src="https://unsplash.it/100/100?image=1005"
                                             th:src="@{${reply.avatar}}">
                                    </a>
                                    <div class="content">
                                        <a class="author">
                                            <span th:text="${reply.nickname}">小红</span>
                                            <div class="ui mini orange label m-padded-mini"
                                                 th:if="${reply.adminComment}">博主
                                            </div>
                                            &nbsp;<span th:text="|@ ${reply.parentComment.nickname}|"
                                                        style="color: #03c39a">@ 小白</span>
                                        </a>
                                        <div class="metadata">
                                        <span class="date"
                                              th:text="${#dates.format(reply.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                        </div>
                                        <div class="text" th:text="${reply.content}">
                                            How artistic!
                                        </div>
                                        <div class="actions">
                                            <a class="reply" data-commentid="1" data-commentnickname="Matt"
                                               th:attr="data-commentid=${reply.id},data-commentnickname=${reply.nickname}"
                                               onclick="reply(this)">回复</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--/*-->
                        <div class="comment">
                            <a class="avatar">
                                <img class="img" src="https://unsplash.it/100/100?image=1005">
                            </a>
                            <div class="content">
                                <a class="author">Elliot Fu</a>
                                <div class="metadata">
                                    <span class="date">Yesterday at 12:30AM</span>
                                </div>
                                <div class="text">
                                    <p>This has been very useful for my research. Thanks as well!</p>
                                </div>
                                <div class="actions">
                                    <a class="reply">回复</a>
                                </div>
                            </div>
                            <div class="comments">
                                <div class="comment">
                                    <a class="avatar">
                                        <img class="img" src="https://unsplash.it/100/100?image=1005">
                                    </a>
                                    <div class="content">
                                        <a class="author">Jenny Hess</a>
                                        <div class="metadata">
                                            <span class="date">Just now</span>
                                        </div>
                                        <div class="text">
                                            Elliot you are always so right :)
                                        </div>
                                        <div class="actions">
                                            <a class="reply">回复</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="comment">
                            <a class="avatar">
                                <img class="img" src="https://unsplash.it/100/100?image=1005">
                            </a>
                            <div class="content">
                                <a class="author">Joe Henderson</a>
                                <div class="metadata">
                                    <span class="date">5 days ago</span>
                                </div>
                                <div class="text">
                                    Dude, this is awesome. Thanks so much
                                </div>
                                <div class="actions">
                                    <a class="reply">回复</a>
                                </div>
                            </div>
                        </div>
                        <!--*/-->

                    </div>
                </div>
            </div>
            <!-- 发布留言区域 -->
            <div id="comment-form" class="ui form">
                <input type="hidden" name="blog.id" th:value="${blog.id}">
                <input type="hidden" name="parentComment.id" value="-1">
                <div class="field">
                    <textarea name="content" placeholder="请输入评论信息..."></textarea>
                </div>
                <div class="fields">
                    <div class="field m-mobile-wide">
                        <div class="ui left icon input">
                            <i class="user icon"></i>
                            <input type="text" name="nickname" placeholder="昵称"
                                   th:value="${session.user}!=null ? ${session.user.nickname}">
                        </div>
                    </div>
                    <div class="field m-mobile-wide">
                        <div class="ui left icon input">
                            <i class="mail icon"></i>
                            <input type="text" name="email" placeholder="邮箱"
                                   th:value="${session.user}!=null ? ${session.user.email}">
                        </div>
                    </div>
                    <div class="field m-mobile-wide">
                        <button id="commentpost-btn" type="button" class="ui teal button m-mobile-wide"><i
                                class="edit icon"></i> 发布留言
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<div class="m-fixed m-right-bottom m-padded">
    <!-- 导航栏 -->
    <div id="toolbar" class="ui vertical icon buttons " style="display: none;">
        <div id="buttom-botton" class="ui teal button">留言</div>
        <button class="ui wechat icon button"><i class="mobile alternate icon" title="手机查看"></i></button>
        <div id="top-botton" class="ui icon button"><i class="chevron up icon"></i></div>
    </div>
    <!-- 二维码 -->
    <div id="qrcode" class="ui wechat-qr flowing popup transition hidden" style="width: 130px ! important;">
        <!-- <img src="./static/images/zfb.png" alt="" class="ui rounded image" style="width: 120px !important;"> -->
    </div>
    <!-- 右侧目录 -->
    <div style="position: absolute; top: -500px; right: 100px; width: 100%; font-size: 20px; height: 50px;">
        <ol class="js-toc">
        </ol>
    </div>
</div>

<br>
<br>


<!-- 底部footer -->
<footer th:replace="_fragments :: footer"></footer>

</body>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<script src="../static/lib/prism/prism.js" th:src="@{/lib/prism/prism.js}"></script>
<script src="../static/lib/tocbot/tocbot.min.js" th:src="@{/lib/tocbot/tocbot.min.js}"></script>
<script src="../static/lib/qrcode/qrcode.min.js" th:src="@{/lib/qrcode/qrcode.min.js}"></script>
<script src="../static/lib/waypoints/jquery.waypoints.min.js"
        th:src="@{/lib/waypoints/jquery.waypoints.min.js}"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery.scrollto@2.1.3/jquery.scrollTo.min.js"></script>
<!-- 引入组件库 -->
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>

<!--音乐播放器-->
<div class="aplayer" data-id="2243870076" data-server="netease" data-type="playlist" data-fixed="true"
     data-autoplay="true" data-volume="0.6"></div>
<script>var meting_api = 'http://api.mizore.cn/meting/api.php?server=:server&type=:type&id=:id'</script>
<script src="http://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script>
<script src="http://cdn.jsdelivr.net/npm/meting@1.2.0/dist/Meting.min.js"></script>
<script type="text/javascript" th:src="@{/js/ribbon.js}"></script>
<script type="text/javascript" th:src="@{/js/mouse.js}"></script>

<script th:inline="javascript">

    // element ui 初始化
    new Vue({
        el: '#app',
        data: function () {
            return {
                visible: false,
                url1: '/images/zfb.png',
                url2: '/images/weixin.png'
            }
        }
    });

    $('.wechat').popup({
        popup: $('.wechat-qr'),
        position: 'left center'
    });


    // 隐藏显示
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
        return false;
    });

    // 目录工具初始化
    tocbot.init({
        // Where to render the table of contents.
        tocSelector: '.js-toc',
        // Where to grab the headings to build the table of contents.
        contentSelector: '.js-toc-content',
        // Which headings to grab inside of the contentSelector element.
        headingSelector: 'h1, h2, h3',
        // For headings inside relative or absolute positioned containers within content.
        hasInnerContainers: true,
    });

    // 手机端二维码
    var serurl = /*[[#{blog.serUrl}]]*/"127.0.0.1:8080";
    var url = /*[[@{blog/{id}(id=${blog.id})}]]*/"";
    var qrcode = new QRCode("qrcode", {
        text: serurl + url,
        width: 128,
        height: 128,
        colorDark: "#000000",
        colorLight: "#ffffff",
        correctLevel: QRCode.CorrectLevel.H
    });


    // 滑动到顶部
    $('#top-botton').click(function () {
        $(window).scrollTo(0, 600)
    })
    // 滑动到留言部分
    $('#buttom-botton').click(function () {
        $(window).scrollTo('#comment-container', 600)
    })

    // 滑动侦测，默认隐藏右下角组件，下滑显示
    var waypoint = new Waypoint({
        element: document.getElementById('waypoint'),
        handler: function (direction) {
            if (direction == 'down') {
                $('#toolbar').show(500);
            } else {
                $('#toolbar').hide(500);
            }
        }
    })

    //    表单验证
    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '请输入评论内容'
                }]
            },
            content: {
                identifier: 'nickname',
                rules: [{
                    type: 'empty',
                    prompt: '请输入您的昵称'
                }]
            },
            type: {
                identifier: 'email',
                rules: [{
                    type: 'email',
                    prompt: '请输入正确邮箱地址'
                }]
            }
        }
    });

    $('#commentpost-btn').click(function () {
        var boo = $('.ui.form').form('validate form');
        if (boo) {
            // console.log("校验通过")
            postData();
        } else {

            // console.log("校验不通过");
        }
    });

    $(function () {
        $("#comment-container").load(/*[[@{/comments/{id}(id=${blog.id})}]]*/"comments/6");
    });

    function postData() {
        $("#comment-container").load(/*[[@{/comments}]]*/"", {
            "parentComment.id": $("[name='parentComment.id']").val(),
            "blog.id": $("[name='blog.id']").val(),
            "nickname": $("[name='nickname']").val(),
            "email": $("[name='email']").val(),
            "content": $("[name='content']").val()
        }, function (responseTxt, statusTxt, xhr) {
            clearContent();
        });
    }

    function clearContent() {
        $("[name='content']").val('');
        $("[name='parentComment.id']").val(-1);
        $("[name='content']").attr("placeholder", "请输入评论信息...");
    }

    function reply(obj) {
        var commentId = $(obj).data('commentid');
        var commentNickname = $(obj).data('commentnickname');
        $("[name='content']").attr("placeholder", "@" + commentNickname).focus();
        $("[name='parentComment.id']").val(commentId);
        $(window).scrollTo('#comment-form', 500);
    }

</script>

<script>
    //图片查看器作用域
    $(".forFlow img").each(function () {
        var element = document.createElement("a");
        $(element).attr("data-fancybox", "gallery");
        $(element).attr("href", $(this).attr("src"));
        $(this).wrap(element);
    });
</script>

<!--图片查看器-->
<script type="text/javascript" src="https://cdn.bootcss.com/fancybox/3.5.7/jquery.fancybox.js"></script>
<link rel="stylesheet" href="https://cdn.bootcss.com/fancybox/3.5.7/jquery.fancybox.css">
</html>